# Configuration for Linux on ARM.
# Generating binaries for the ARMv7-a architecture and higher
#
ARCH_ARM_HAVE_THUMB_SUPPORT     := true
ARCH_ARM_HAVE_FAST_INTERWORKING := true
ARCH_ARM_HAVE_64BIT_DATA        := true
ARCH_ARM_HAVE_HALFWORD_MULTIPLY := true
ARCH_ARM_HAVE_CLZ               := true
ARCH_ARM_HAVE_FFS               := true
ARCH_ARM_HAVE_ARMV7A            := true
ARCH_ARM_HAVE_VFP               := true

# Note: Hard coding the 'tune' value here is probably not ideal,
# and a better solution should be found in the future.
#
arch_variant_cflags := \
    -march=armv7-a \
    -mfloat-abi=softfp \
    -mfpu=vfpv3-d16

arch_variant_ldflags := \
	-Wl,--fix-cortex-a8

TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined

TARGET_GLOBAL_CFLAGS += \
                        -msoft-float -fpic \
                        -ffunction-sections \
                        -fdata-sections \
                        -funwind-tables \
                        -fstack-protector \
                        -Wa,--noexecstack \
                        -Werror=format-security \
                        -fno-short-enums \
                        $(arch_variant_cflags) 

# This is to avoid the dreaded warning compiler message:
#   note: the mangling of 'va_list' has changed in GCC 4.4
#
# The fact that the mangling changed does not affect the NDK ABI
# very fortunately (since none of the exposed APIs used va_list
# in their exported C++ functions). Also, GCC 4.5 has already
# removed the warning from the compiler.
#
TARGET_GLOBAL_CFLAGS += -Wno-psabi
TARGET_GLOBAL_LDFLAGS := \
                        -Wl,-z,noexecstack \
                        -Wl,--gc-sections,--icf=safe \
                        $(arch_variant_ldflags)

# We only need thumb interworking in cases where thumb support
# is available in the architecture, and just to be sure, (and
# since sometimes thumb-interwork appears to be default), we
# specifically disable when thumb support is unavailable.
ifeq ($(ARCH_ARM_HAVE_THUMB_SUPPORT),true)
TARGET_GLOBAL_CFLAGS += -mthumb-interwork
else
TARGET_GLOBAL_CFLAGS += -mno-thumb-interwork
endif

TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden

ifneq ($(ENABLE_DEBUG),true)
# More flags/options can be added here
TARGET_RELEASE_CFLAGS := \
                        -DNDEBUG \
                        -Wstrict-aliasing=2 \
                        -fgcse-after-reload \
                        -frerun-cse-after-loop \

TARGET_GLOBAL_CFLAGS += $(TARGET_RELEASE_CFLAGS)
endif

